<!DOCTYPE html>
<html lang="en">

<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>订单</title>
	<link href="/static/css/bootstrap.min.css" rel="stylesheet">
	<link href="/static/css/animate.min.css" rel="stylesheet">
	<link href="/static/css/main.css" rel="stylesheet">
	<link href="/static/css/page.css" rel="stylesheet">
	<link href="/static/css/responsive.css" rel="stylesheet">
	<link href="/static/iconfont/iconfont.css" rel="stylesheet" />
	<link href="/static/css/al.css" rel="stylesheet" />
	<link href="/static/css/buttons.css" rel="stylesheet" />
	<link href="/static/css/pages-myOrder.css" rel="stylesheet" />
	<link href="/static/css/person.css" rel="stylesheet" />
	<link href="/static/css/rese.css" rel="stylesheet" />
	<link href="/static/css/use.css" rel="stylesheet" />

	<script src="/static/js/jquery.js"></script>
	<script src="/static/js/bootstrap.min.js"></script>
	<script src="/static/js/jquery.SuperSlide.js" type="text/javascript"></script>
	<script src="/static/js/NSW_Index.js"></script>
	<link href="css/bootstrap.min.css" rel="stylesheet">
	<link href="/static/css/animate.min.css" rel="stylesheet">
	<link href="/static/css/main.css" rel="stylesheet">
	<link href="/static/css/page.css" rel="stylesheet">
	<link href="/static/css/responsive.css" rel="stylesheet">
	<link href="/static/iconfont/iconfont.css" rel="stylesheet" />
	<link href="/static/css/al.css" rel="stylesheet" />
	<link href="/static/css/buttons.css" rel="stylesheet" />
	<link href="/static/css/pages-myOrder.css" rel="stylesheet" />
	<link href="/static/css/person.css" rel="stylesheet" />
	<link href="/static/css/rese.css" rel="stylesheet" />
	<link href="/static/css/use.css" rel="stylesheet" />

	<script src="/static/js/jquery.js"></script>
	<script src="/static/js/bootstrap.min.js"></script>
	<script src="/static/js/jquery.SuperSlide.js" type="text/javascript"></script>
	<script src="/static/js/NSW_Index.js"></script>
	<link rel="stylesheet" type="text/css" href="/static/css/all.css" />
	<link rel="stylesheet" type="text/css" href="/static/css/pages-myOrder.css" />'
	<link rel="stylesheet" href="/static/js/jquery-3.6.4.min.js">
	<script type="text/javascript" src="/static/js/all.js"></script>

</head>

<body>
	<header id="header">
		<nav class="navbar navbar-inverse" role="banner">
			<div class="container">
				<div class="row">
					<div class="col-md-3 navbar-header">
						<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
							<span class="sr-only">Toggle navigation</span>
							<span class="icon-bar"></span>
							<span class="icon-bar"></span>
							<span class="icon-bar"></span>
						</button>
						<a class="navbar-brand" href="index.html"><img src="/static/images/logo.png" alt="logo" class="img-responsive"></a>
					</div>
					<div class="col-md-9">
						<div class="tel">24小时服务热线：<span>0755-29961998</span></div>
						<div class="collapse navbar-collapse navbar-right">
							<ul class="nav navbar-nav">
								<li><a href="http://127.0.0.1:8000/publish/model_view/">订单类型</a></li>
								<li class="active"><a href="http://127.0.0.1:8000/order/order_list_view/">我的订单</a></li>
								<li><a href="http://127.0.0.1:8000/evaluation/list_view/">我的评价</a></li>
								<li><a href="http://127.0.0.1:8000/user/user_view/">我的信息</a></li>


							</ul>
						</div>
					</div>
				</div>
			</div>
		</nav>
	</header>
	<div class="banner2">
		<p style="background:url(/static/images/banner1.jpg) no-repeat center; background-size:cover;"></p>
	</div>
	<div id="account">
		<div class="py-container">
			<div class="yui3-g home">
				<!--右侧主内容-->
				<div class="yui3-u-5-6 body">
					<div class="order">
						<div class="mt">
							<span class="fl"><strong>我的订单</strong></span>
						</div>
					</div>

					<div class="order-detail">

						<div class="ever">
							<ul class="sui-nav nav-tabs">
								<li class="active">
									<a id="all" href="" data-toggle="tab">全部订单</a>
								</li>
								<li>
									<a id="receive" href="" data-toggle="tab">未接单</a>
								</li>
								<li>
									<a id="pay" href="" data-toggle="tab">处理中</a>
								</li>
								<li>
									<a id="remark" href="" data-toggle="tab">已完成</a>
								</li>
								<li>
									<a id="delete" href="" data-toggle="tab">已失效</a>
								</li>
							</ul>
							<div class="clearfix"></div>

							<div class="tab-content">
								<div class="chosetype">
									<table class="sui-table table-bordered-simple">
										<thead>
											<tr>
												<th width="29%">
													<span><span class="dropdown-inner">
															<span> &nbsp;&nbsp; 尊敬的客户！您好 &nbsp;&nbsp;</span>
														</span></span>
												</th>
												<th width="26.8%">订单地址</th>
												<th width="16.2%">订单内容</th>
												<th width="15%">订单价格</th>
												<th width=> 订单状态</th>


												<th>删除</th>
											</tr>
										</thead>
										</tbody>
									</table>
								</div>

								<div id="content" class="tab-pane active">
									<div class="orders">

									</div>


								</div>
							</div>
						</div>

					</div>
				</div>
			</div>
		</div>
	</div>
	<script>
		token = window.localStorage.getItem('moh_token');
		username = window.localStorage.getItem('moh_user');
		status_val = 0
		function a(username, token) {
			$.ajax({
				type: "get",
				url: "http://127.0.0.1:8000/order/order_list/" + username + "/" + status_val,
				beforeSend: function (request) {
					request.setRequestHeader("Authorization", token);
				},
				success: function (data) {

					var html = ""
					if (data.code == 200) {
						var order_list = data.data.order_list;
						console.log(data.data.order_list);

						for (var i in order_list) {
							item = order_list[i];
							console.log(item);

							html += "<table class='sui-table table-bordered'>"
							html += "<thead><tr><th colspan='5'>"
							html += "<span class='ordertitle'value=' item.order_code+'>"
							html += "订单编号：" + item.order_code + "<span class='pull-right delete' ><img  id = 'del_" + item.order_code + "' onclick='btnclick(this)' src='/static/images/delete.png' ></span></span></th></tr></thead>";

							html += "<tbody><tr><td width='40%'><div class='typographic'>"
							html += '<img style="width: 238px;height: 159px;" id =' + item.model_code + ' class="clickImage" src="http://127.0.0.1:8000/media/' + item.model_img + '"' + 'alt="">';
							html += "<div href='#' class='block-text'>" + item.address + "</div><span></span><ul class='unstyled list-inline'><li></li></ul></div></td><td rowspan='2'style='text-align:center;' width='20%' >" + item.content + "</td><td rowspan='2' width='15%' style='text-align:center; ><ul class='unstyled'><li>¥" + item.price + "</li><li>在线支付</li></ul></td><td rowspan='2' width='8%'' class='center'><div >" + item.status + "</div></td><td rowspan='2' width='13%'class='center'><ul ><li><a width='13%' id = 'pingjia_" + item.order_code + "' href='' target='_blank' onclick='pingjiaclick(this)'>评价</a> </li></ul></td></tr>"

							html += "<tr><td width='50%'><div class='typographic'><span>订单时间：" + item.date_time + "</span><ul class='unstyled'><li>下单电话：" + item.phone + "</li></ul></div><div>下单人：" + item.name + "</div></td></tr></tbody</table>"
						}

					} else {
						alert(data.error);
					}
					$("#content").html(html);
				}, error: function (e) {
					alert(data);
				}
			})
		}
		if (!username) {
			alert("请先登录")
			window.location.href = 'http://127.0.0.1:8000/user/login_view/';
		} else {
			a(username, token)

		}

		$("#all").on("click", function () {
			status_val = 0
			a(username, token)
		});
		$("#receive").on("click", function () {
			status_val = 1
			a(username, token)
		});
		$("#pay").on("click", function () {
			status_val = 2
			a(username, token)
		});
		$("#remark").on("click", function () {
			status_val = 3
			a(username, token)
		});
		$("#delete").on("click", function () {
			status_val = 4
			a(username, token)
		});
		function btnclick(obj) {
			var order_code = $(obj).attr("id");
			order_code = order_code.replace("del_", "")
			console.log(order_code)
			$.ajax({
				type: "get",
				url: "http://127.0.0.1:8000/order/delete_order/" + username + "/" + order_code,
				beforeSend: function (request) {
					request.setRequestHeader("Authorization", token);
				},
				success: function (data) {
					if (data.code == 200) {
						alert("删除成功");
						a(username, token)
					} else {
						alert(data.error);
					}
				},
				error: function (e) {
					alert(data);
				}
			})
		}
		function pingjiaclick(obj) {
			var order_code = $(obj).attr("id");
			order_code = order_code.replace("pingjia_", "")
			window.location.href = 'http://127.0.0.1:8000/evaluation/evaluation_view/' + order_code;
		}

	</script>
	</script>

	<!-- 安全 Start -->
	<section class="service-v1">
		<div class="container">
			<div class="row">
				<div class="col-sm-4 col-md-4 col-lg-4">
					<div class="item">
						<div class="icon">
							<i class="iconfont">&#xe620;</i>
						</div>
						<div class="text">
							<div class="inner">
								<h3>正规公司，值得信赖</h3>
								<p>工商注册备案，安全可靠！</p>
							</div>
						</div>
					</div>
				</div>
				<div class="col-sm-4 col-md-4 col-lg-4">
					<div class="item">
						<div class="icon">
							<i class="iconfont">&#xe633;</i>
						</div>
						<div class="text">
							<div class="inner">
								<h3>安全保障，持证上岗</h3>
								<p>三证齐全（身份证，健康证，育婴师证）疾病排查，身份联网确认</p>
							</div>
						</div>
					</div>
				</div>
				<div class="col-sm-4 col-md-4 col-lg-4">
					<div class="item">
						<div class="icon">
							<i class="iconfont">&#xe614;</i>
						</div>
						<div class="text">
							<div class="inner">
								<h3>异地服务，更贴心</h3>
								<p>专注母婴护理，你在哪，我们的服务就在哪里</p>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</section>

	<!--footer-->
	<footer id="footer">
		<div class="container">
			<a href="http://127.0.0.1:8000/publish/model_view/">订单类型 </a>
			<a href="http://127.0.0.1:8000/order/order_list_view/">我的订单</a>
			<a href="http://127.0.0.1:8000/evaluation/list_view/">我的评价</a>
			<a href="http://127.0.0.1:8000/user/user_view/">我的信息</a>
			<span>联系地址：深圳宝安西乡街道兴业路西南侧碧海富通城1栋110 &nbsp;&nbsp; 联系方式：0755-29961998<br>
				Copyright © 2005-2023 All rights reserved. 京ICP备10012705号-8 </span>
		</div>
	</footer>
</body>

</html>